<template>
    <view class="content">
        <image class="beiY" src="../../static/beiY.png" mode="aspectFill"></image>
		 <!-- <image class="titel" src="../../static/titel.png" mode="aspectFill"></image> -->
		<view class="gogame" @click="Level"   >
			<!-- <image class="gogameimg" src="../../static/gogame.png" mode="aspectFill"></image> -->
			<text class="Go" >微信登录</text>
		</view>
    </view>
</template>

<script setup lang="ts">
	
  const Scorerequest = (code) => {
	
   uni.request({
   	url: `https://xcx.xiaombt.com/api.php?m=llk.wxlogin&code=${code}`, // 请求的URL
   	method: 'POST', // 请求方法
   	header: {
   		'content-type': 'application/x-www-form-urlencoded', // 请求头 如有需要自行替换
   	},
   	success: function (res) {
		console.log(111111,res);
      uni.setStorageSync('OpenidData', { Openid: res.data }); //注释掉
      uni.setStorageSync('OpenidData', { Openid: {'openid':'123','session_key':'123'} });//注释掉
	  uni.navigateBack()
       if(res.data.openid){
			uni.navigateBack()
       }
     
   	},
   	fail: function (error) {
   	}
   })
  }
  
	
	const Level = () => {
	  uni.getUserProfile({
	    provider: 'weixin',
		desc:'用于帮助您完成注册和登陆',
	    success: function(profile) {
	      console.log(profile, '---userProfile');
	      uni.login({
	        provider: 'weixin',
	        success: function(loginRes) {
	          console.log(loginRes, '---loginRes');
		
	          Scorerequest(loginRes.code);
	        },
	        fail: function(err) {
	          console.error('Login failed:', err);
	        }
	      });
	    },
	    fail: function(err) {
	      console.error('User profile request failed:', err);
	    }
	  });
	}
	
	
</script>

<style scoped>
	image{
		width: 0;
		height: 0;
	}
	
    .content {
        position: fixed;
        top: 0;
        left: 0;
        width: 100vw;
        height: 100vh; 
        z-index: -1; 
    }
    .beiY {
        width: 100%;
        height: 100%;
        object-fit: cover; 
    }
	.titel{
		 position: fixed;
		    top: 385rpx;
		    left: 50%;
		    width: 574rpx;
		    height: 94rpx;
			margin-left: -269rpx;
	}
	.gogame{
		position: fixed;
		   bottom: 40%;
		   left: 50%; 
		   width: 480rpx;
		   height: 96rpx;
			margin-left: -240rpx;
			display: flex;
			justify-content: center;
			align-items: center;
			background-image: url('../../static/login.png');
			background-size: 100%;
	}
	.gogameimg{
			width: 480rpx;
			height: 96rpx;
			
	}
	.Go{
		margin-top: -15rpx;
		position: absolute;
		margin-bottom: 10rpx;
		font-size: 35rpx;
		color: #fff;
		letter-spacing: 15rpx;
		font-weight: bold;
	}

	
	
</style>
